﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PS3Helpers.UserControls
{
    public class ComboBoxItem
    {
        private string _text;
        private object _itemValue;

        public ComboBoxItem(string text, object itemvalue)
        {
            _text = text;
            _itemValue = itemvalue;
        }

        public override string ToString()
        {
            return _text;
        }

        public object ItemValue
        {
            get { return _itemValue; }
        }

        public static void SetSelectedValue(ComboBox combobox, object value)
        {
            foreach (ComboBoxItem item in combobox.Items)
            {
                if ((int)item._itemValue == (int)value)
                {
                    combobox.SelectedItem = item;
                    break;
                }
            }
        }

        public static object GetSelectedValue(ComboBox combobox)
        {
            ComboBoxItem item = (ComboBoxItem)combobox.SelectedItem;
            return item._itemValue;
        }
    }
}
